package com.yy.wga.pay.service.client.request.wechat;

import com.alibaba.fastjson.annotation.JSONField;
import com.yy.wga.pay.service.client.request.BaseRefundRequest;
import com.yy.wga.pay.service.client.response.wechat.WechatRefundResponse;
import com.yy.wga.pay.service.client.request.BaseRefundRequest;
import com.yy.wga.pay.service.client.response.wechat.WechatRefundResponse;
import com.yy.wga.pay.service.client.request.BaseRefundRequest;
import com.yy.wga.pay.service.client.response.wechat.WechatRefundResponse;
import com.yy.wga.pay.service.client.request.BaseRefundRequest;
import com.yy.wga.pay.service.client.response.wechat.WechatRefundResponse;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
* Created by gc on 2021/8/29.
*
* @author : gc
*
* Description: 转账接口公共参数
**/
@Data
public class WechatRefundRequest extends BaseRefundRequest<WechatRefundResponse> {
    private static final long serialVersionUID = -7936199157707126493L;

    /**
     * 微信支付订单号
     */
    @JSONField(name = "transaction_id")
    private String transactionId;

    /**
     * 商户订单号
     */
    @JSONField(name = "out_trade_no")
    private String outTradeNo;

    /**
     * 商户系统内部的退款单号
     */
    @JSONField(name = "out_refund_no")
    @NotBlank
    private String outRefundNo;

    /**
     * 退款原因
     */
    private String reason;

    /**
     * 异步通知地址
     */
    @JSONField(name = "notify_url")
    private String notifyUrl;

    /**
     * 订单金额信息
     */
    @NotNull
    private Amount amount;

    /**
     * 指定商品退款需要传此参数
     */
    @JSONField(name = "goods_detail")
    private List<GoodsDetail> goodsDetail;

    @Data
    public static class Amount {

        /**
         * 退款金额，单位为分
         */
        @NotNull
        private Long refund;

        /**
         * 退款需要从指定账户出资时
         */
        private List<From> from;

        /**
         * 原支付交易的订单总金额，单位为分
         */
        @NotNull
        private Long total;

        /**
         * CNY：人民币，境内商户号仅支持人民币。
         */
        private String currency;

        @Data
        public static class From {

            /**
             * 出资账户类型，AVAILABLE : 可用余额，UNAVAILABLE : 不可用余额
             */
            private String account;

            /**
             * 出资金额，单位分
             */
            private Long amount;
        }
    }

    @Data
    public static class GoodsDetail {

        /**
         * 商户侧商品编码
         */
        @JSONField(name = "merchant_goods_id")
        @NotBlank
        private String merchantGoodsId;

        /**
         * 微信侧商品编码
         */
        @JSONField(name = "wechatpay_goods_id")
        private String wechatpayGoodsId;

        /**
         * 商品名称
         */
        @JSONField(name = "goods_name")
        private String goodsName;

        /**
         * 商品单价
         */
        @JSONField(name = "unit_price")
        private Long unit_price;

        @JSONField(name = "refund_amount")
        /**
         * 商品退款金额，单位为分
         */
        private Long refundAmount;

        /**
         * 单品的退款数量
         */
        @JSONField(name = "refund_quantity")
        private Long refundQuantity;

    }
}
